package com.jtny.nytb.config.dictionary.vo;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.jtny.component.dto.CurrentUserDTO;
import com.jtny.component.entity.LocalHolder;
import com.jtny.component.enums.GenericStatusEnum;
import com.jtny.component.util.CurrentUserUtils;
import com.jtny.nytb.config.dictionary.dto.DictionaryDTO;
import lombok.Data;

import java.io.Serializable;

/**
 * @author 智慧能源中心 - 伍天宇
 * @package com.jtny.nytb.config.generic.dictionary.vo
 * @fileName DictionaryExcelVO.java
 * @createTime 2023年11月10日 09:45
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Data
@ExcelIgnoreUnannotated
public class ExcelDictionaryVO implements Serializable {

    /**
     * 数据字典编号 ^[a-zA-Z0-9_]+$
     */
    @ExcelProperty("数据字典编号")
    @ColumnWidth(30)
    private String code;

    /**
     * 数据字典名称
     */
    @ExcelProperty("数据字典名称")
    @ColumnWidth(30)
    private String name;

    /**
     * 数据字典描述
     */
    @ExcelProperty("数据字典描述")
    @ColumnWidth(30)
    private String description;


    public DictionaryDTO toDictionaryDTO(){
        DictionaryDTO dictionaryDTO = new DictionaryDTO();
        dictionaryDTO.setCode(this.code);
        dictionaryDTO.setName(this.name);
        dictionaryDTO.setDescription(this.description);
        dictionaryDTO.setStatus(GenericStatusEnum.NORMAL.getValue());
        CurrentUserDTO currentUser = LocalHolder.getCurrentUser();
        CurrentUserUtils.setCreateDefaultField(dictionaryDTO, currentUser);
        return dictionaryDTO;
    }
}
